<?php

namespace catchAdmin\hunqing\controller;

use catcher\base\CatchRequest as Request;
use catcher\CatchResponse;
use catcher\base\CatchController;
use catchAdmin\hunqing\model\Userinfo as UserinfoModel;
use think\Response;

class Userinfo extends CatchController
{
    
    protected $userinfoModel;
    
    /**
     *
     * @time 2025/04/28 20:47
     * @param UserinfoModel $userinfoModel
     * @return mixed
     */
    public function __construct(UserinfoModel $userinfoModel)
    {
        $this->userinfoModel = $userinfoModel;
    }
    
    /**
     *
     * @time 2025/04/28 20:47
     * @return Response
     */
    public function index() : Response
    {
        return CatchResponse::paginate($this->userinfoModel->getList());
    }
    
    /**
     *
     * @time 2025/04/28 20:47
     * @param Request $request
     * @return Response
     */
    public function save(Request $request) : Response
    {

        return CatchResponse::success($this->userinfoModel->storeBy($request->post()));
    }
    
    /**
     *
     * @time 2025/04/28 20:47
     * @param $id
     * @return Response
     */
    public function read($id) : Response
    {
        return CatchResponse::success($this->userinfoModel->findBy($id));
    }
    
    /**
     *
     * @time 2025/04/28 20:47
     * @param $id
     * @param Request $request
     * @return Response
     */
    public function update($id, Request $request) : Response
    {

        return CatchResponse::success($this->userinfoModel->updateBy($id, $data));
    }
    
    /**
     *
     * @time 2025/04/28 20:47
     * @param $id
     * @return Response
     */
    public function delete($id) : Response
    {
        return CatchResponse::success($this->userinfoModel->deleteBy($id));
    }
}